using NLog;

namespace zhwy.saas.api.Extensions.Log
{
    public class LogExt : ILogExt
    {
        private readonly NLog.ILogger _logger;

        public LogExt()
        {
            _logger = LogManager.GetCurrentClassLogger();
        }

        public void Debug(string message)
        {
            _logger.Debug(message);
        }

        public void Debug<T>(string message, T context)
        {
            _logger.Debug($"{message}, Context: {System.Text.Json.JsonSerializer.Serialize(context)}");
        }

        public void Info(string message)
        {
            _logger.Info(message);
        }

        public void Info<T>(string message, T context)
        {
            _logger.Info($"{message}, Context: {System.Text.Json.JsonSerializer.Serialize(context)}");
        }

        public void Warn(string message)
        {
            _logger.Warn(message);
        }

        public void Warn<T>(string message, T context)
        {
            _logger.Warn($"{message}, Context: {System.Text.Json.JsonSerializer.Serialize(context)}");
        }

        public void Error(string message)
        {
            _logger.Error(message);
        }

        public void Error(Exception ex)
        {
            _logger.Error(ex);
        }

        public void Error<T>(string message, T context)
        {
            _logger.Error($"{message}, Context: {System.Text.Json.JsonSerializer.Serialize(context)}");
        }

        public void Error(Exception ex, string message)
        {
            _logger.Error(ex, message);
        }
    }
}